package org.ldx.lotterysystem.dao.mapper;

import org.apache.ibatis.annotations.*;
import org.ldx.lotterysystem.dao.dataobject.ActivityDo;

import java.util.List;

@Mapper
public interface ActivityMapper {
    @Insert("insert into activity (activity_name,description,status)" +
            "values (#{activityName},#{description},#{status})")
    @Options(useGeneratedKeys = true,keyProperty = "id",keyColumn = "id")
    int insertActivity(ActivityDo activityDo);
    @Select("select count(1) from activity")
    int count();
    @Select("select * from activity order by id desc limit #{offset},#{pageSize}")
    List<ActivityDo> selectActivityList(Integer offset, Integer pageSize);

    /**
     *跟据活动id查询活动信息
     * @param activityId
     * @return
     */
    @Select("select * from activity where id = #{activity}")
    ActivityDo selectById(Long activityId);

    /**
     * 更新活动状态为目标状态
     * @param activityId
     * @param name
     */
    @Update("update activity set status = #{name} where id = #{activityId}")
    void updateStatus(Long activityId, String name);
}
